package com.freedom.admin.infrastructure.persistence.repository;

import com.freedom.admin.domain.repository.RolePermissionRepository;
import com.freedom.admin.infrastructure.persistence.mapper.SysRolePermissionMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class RolePermissionRepositoryImpl implements RolePermissionRepository {

    private final SysRolePermissionMapper rolePermissionMapper;

    @Override
    public List<Integer> findPermissionIdsByRoleId(Integer roleId) {
        return rolePermissionMapper.selectPermissionIdsByRoleId(roleId);
    }

    @Override
    public void addRolePermission(Integer roleId, List<Integer> permIds) {
        rolePermissionMapper.insertRolePermission(roleId, permIds);
    }

    @Override
    public void removeRolePermission(Integer roleId, List<Integer> permIds) {
        rolePermissionMapper.deleteRolePermission(roleId, permIds);
    }
}
